<style type="text/css">
	.bjui-pageHeader{
	        font-size: 18px;
	        font-weight: bold;
	    }
	    .form{
	        padding: 15px;
	    }
	    .form dl {
	        overflow: hidden;
	        padding-top: 15px;
	    }
	
	    .form dt {
	        color: #666;
	        float: left;
	        font-size: 14px;
	        padding: 3px 0 0;
	        width: 11%;
	    }
	    .form dd {
	        float: left;
	        line-height: 22px;
	    }
	    dd.desc {
	        height: 30px;
	        padding: 0 10px;
	        width: 150px;
	    }
	    .litpic_btn,.file_btn{
	        float: right;
	    }
</style>

<!--  -->
<script type="text/javascript">
	$(function () {
	
	        //文件上传
	        var file_tip = $(".file_tip");
	        var filebtn = $(".file_btn span");
	        $("#fileuploadF").wrap("<form id='myfileuploadform' action='{:U('Site/uploadDocs',array('dir'=>'file'))}' method='post' enctype='multipart/form-data'></form>");
	        $("#fileuploadF").change(function () {
	            if ($("#fileuploadF").val() == "") return;
	            $("#myfileuploadform").ajaxSubmit({
	                dataType: 'json',
	                beforeSend: function () {
	                    filebtn.html("上传中...");
	                    file_tip.html("上传中...");
	                },
	                success: function (data) {
	                    if (data.status == '1') {
	                        file_tip.html("" + data.title + " 上传成功(" + data.size + "k)");
	                        $('#downlink').val("本地下载$$$" + data.path + '\n' + $('#downlink').val());
	                        //$("#fileurl").val(data.url);
	                        $("#filesize").val(data.size + "KB");
	                    } else {
	                        file_tip.html(data.info);
	                    }
	                    filebtn.html("添加文件");
	
	                },
	                error: function (xhr) {
	                    filebtn.html("上传失败");
	                    file_tip.html(xhr.info);
	                }
	            });
	        });
	
	        //跳转链接
	        $('#CK_JumpUrl').click(function(){
	            var inputs = $(this).parents('dl').find('input');
	            if($(this).attr('checked')) {
	                $('#JumpUrlDiv').show();
	
	            }else {
	                $('#JumpUrlDiv').hide();
	            }
	
	        });
	
	        //浏览上传的文件
	        var editor = KindEditor.editor({
	            fileManagerJson : '{:U("Attachment/filemanager")}'
	        });
	        $('#BrowerPicture').click(function() {
	            editor.loadPlugin('filemanager', function() {
	                editor.plugin.filemanagerDialog({
	                    viewType : 'VIEW',
	                    dirName : 'image',
	                    clickFn : function(url, title) {
	                        $('#litpic').val(url);
	                        editor.hideDialog();
	                    }
	                });
	            });
	        });
	        $('#BrowerFile').click(function() {
	            editor.loadPlugin('filemanager', function() {
	                editor.plugin.filemanagerDialog({
	                    viewType : 'LIST',
	                    dirName : 'file',
	                    clickFn : function(url, title) {
	                        $('#downlink').val("本地下载$$$" + url + '\n' + $('#downlink').val());
	                        editor.hideDialog();
	                    }
	                });
	            });
	        });
			$('#save').click(function(){
				$('#form').submit();
			});
	
	
	    });
</script>

<script type="text/javascript" src="__PUBLIC__/js/jquery.form.min.js"></script>

<script type="text/javascript" charset="utf-8">
	KindEditor.create('#j_form_content', {
	        uploadJson : '{:U("Attachment/uploads")}',
	        fileManagerJson : '{:U("Attachment/filemanager")}',
	        emoticonsPath:'/Public/UI/resource/emoticons/images/',
	        allowFileManager : true,
	        extraFileUploadParams: {
	            session_id : '<?php echo session_id() ?>'
	        },
	        height : 400,
	        afterBlur: function () {
	            this.sync();
	        }
	    });
</script>

<!-- -->
<div class="bjui-pageHeader">
	<div class="glyphicon glyphicon-th-large">添加下载</div>
</div>
<div class="bjui-pageContent">
	<div class="form">
		<form method='post' data-toggle="validate" action="{:U('Download/edit')}" id="form">
			<table class="table table-bordered table-hover table-striped table-top">
				<tr>
					<td> 名称：</td>
					<td>
						<input type="text" name="title" value="{$vo.title}" size="30" />
					</td>
				</tr>
				<tr>
					<td>标题颜色：</td>
					<td>
						<input type="text" value="{$vo.color}" name="color" data-toggle="colorpicker" id="color" data-bgcolor="true" readonly="" />
					</td>
				</tr>
				<tr>
					<td> 自定义属性：</td>
					<td>
						<foreach name='flagtypelist' item='v'>
							<label>
								<input type='checkbox' name='flags[]' value='{$key}' <if condition="$key eq B_JUMP">id="CK_JumpUrl"</if>
								<if condition="(in_array($key,$vo['flag']))">checked="checked"</if> /> {$v}</label>&nbsp;
						</foreach>
					</td>
				</tr>

				<tr>
					<td> 更新时间：</td>
					<td>
						<input type="text" class="inp_one" name="updatetime" id="updatetime" data-toggle="datepicker" data-pattern="yyyy-MM-dd H:m:s" data-mmStep="1" data-ssStep="1" value="{$vo.updatetime|date='Y-m-d',###}">

					</td>
				</tr>
				<tr>
					<td> 所属栏目：</td>
					<td>
						<select name="cid" data-toggle="selectpicker" data-width="200">
							<foreach name='cate' item='v'>
								<option value="{$v.id}" <if condition="$vo.cid eq $v['id']">selected="selected"</if>>{$v.delimiter}{$v.name}</option>
							</foreach>
						</select>
					</td>
				</tr>
				<tr>
					<td> 缩略图：</td>
					<td>

						<input type="text" name="litpic" id="litpic" value="{$vo.litpic}" />
						<button type="button" class="btn-default" data-icon="folder" id="BrowerPicture">选择站内图片</button>
						<div style="display:inline-block; vertical-align:middle;">
							<div id="doc_pic_up" data-toggle="upload" data-uploader="{:U('Attachment/uploadPlus',array('dir'=>'image'))}" data-file-size-limit="1024000000" data-file-type-exts="*.jpg;*.png;*.gif;*.mpg" data-multi="true" data-on-upload-success="doc_upload_success"
							data-icon="cloud-upload">
							</div>
						</div>

					</td>
				</tr>

				<tr>
					<td> 文件上传：</td>
					<td>
						<div class="file_show">
							<div style="float:left;">
								<button type="button" class="btn-default" id="BrowerFile" data-icon="folder">选择站内文件</button>
								<div class="file_btn">
									<input id="fileuploadF" type="file" name="myfile">
								</div>
								<div class="file_tip"></div>
							</div>
					</td>
				</tr>
				<tr>
					<td> 文件大小：</td>
					<td>
						<input type="text" name="filesize" id="filesize" class="input-nm" size="30" value="{$vo.filesize}" />
					</td>
				</tr>
				<tr>
					<td> 下载地址：</td>
					<td>
						<div>一行一个地址,以$$$分割，如
							<br/>下载地址1$$$http://a.com</div>
						<textarea name="downlink" id="downlink" class="tarea_default" cols="60" rows="5">{$vo.downlink}</textarea>
					</td>
				</tr>
				<tr>
					<td> 内容：</td>
					<td>
						<textarea name="content" id="j_form_content" class="j-content" style="width: 700px;" data-toggle="kindeditor" data-minheight="400">{$vo.content}</textarea>
					</td>
				</tr>

				<tr>
					<td> 关键词：</td>
					<td>
						<input type="text" name="keywords" class="inp_w250" class="input-nm" size="30" value="{$vo.keywords}" />
					</td>
				</tr>
				<tr>
					<td> 摘要：</td>
					<td>
						<textarea name="description" class="tarea_default" cols="30" rows="5">{$vo.description}</textarea>
					</td>
				</tr>

				<tr>
					<td> 发布时间：</td>
					<td>

						<input type="text" class="inp_one" name="publishtime" id="publishtime" value="{$vo.publishtime|date='Y-m-d H:i:s',###}" data-toggle="datepicker" data-pattern="yyyy-MM-dd H:m:s" data-mmStep="1" data-ssStep="1">

					</td>
				</tr>

				<tr>
					<td> 评论：</td>
					<td>
						<input type="radio" name="commentflag" value="1" <if condition='$vo.commentflag eq 1'>checked="checked"</if> />允许
						<input type="radio" name="commentflag" value="0" <if condition='$vo.commentflag eq 0'>checked="checked"</if> />禁止
					</td>
				</tr>
				<input type="hidden" name="id" value="{$vo.id}" />
				<input type="hidden" name="pid" value="{$pid}" />
			</table>
		</form>

		</div>
	</div>
	<div class="bjui-pageFooter">
		<ul>
			<li>
				<button type="button" class="btn-close" data-icon="close">关闭</button>
			</li>
			<li>
				<button data-icon="save" class="btn btn-default" type="submit" id="save">保存</button>
			</li>
		</ul>
	</div>